/* eslint valid-jsdoc: "off" */

'use strict';

const path = require('path');

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};
  config.cors = {
    // enable: false,
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
  };
  config.jwt = {
    secret: '123456',
  };
  config.io = {
    namespace: {
      '/': {
        connectionMiddleware: [],
        packetMiddleware: [],
      },
    }
  };
  config.security = {
    csrf: {
      enable: false,
    }
  }
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1596506284256_8525';

  // add your middleware config here
  config.middleware = ['getParams'];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.static = {
    // 静态化访问前缀,如：`http://127.0.0.1:7001/static/images/logo.png`
    prefix: '/static',
    dir: [path.join(appInfo.baseDir, 'app/public'), path.join(appInfo.baseDir, 'app/web')], // `String` or `Array:[dir1, dir2, ...]` 静态化目录,可以设置多个静态化目录
    dynamic: true, // 如果当前访问的静态资源没有缓存，则缓存静态文件，和`preload`配合使用；
    preload: false,
    maxAge: 31536000, // in prod env, 0 in other envs
    buffer: true, // in prod env, false in other envs
  };
  config.fullQiniu = {
    default: {
      ak: 'IYe0gw8UokETMTzlSK90sAhZG8uKU4mvtfOrjNoR', // Access Key
      sk: 'PETigMluzETup4-FzOAxrLNVOadaQ73AdHGW3QpY', // Secret Key
      useCdnDomain: true,
      isLog: true,
    },
    client: {
      zone: 'Zone_z1', // Zone_z0 华东, Zone_z1 华北, Zone_z2 华南, Zone_na0 北美
      bucket: 'guoshiying-qiniu',
      baseUrl: 'http://qiniu.guoshiying.xyz/', // 用于拼接已上传文件的完整地址
    },
    app: true,
    agent: false,
  }
  config.mysql = {
    // 单数据库信息配置
    client: {
      // host
      // host: 'api.guoshiying.xyz',
      host: '127.0.0.1',
      // 端口号
      port: '3306',
      // 用户名
      // user: 'guo',
      user: 'root',
      // 密码
      password: '',
      // password: '123456',
      // 数据库名
      database: 'guo',
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };

  return {
    ...config,
    ...userConfig,
  };
};
